#ifndef __BINARYSORTTREE_H_
#define __BINARYSORTTREE_H_

#define ElementType void*

typedef struct BinarySortTreeNode
{
    ElementType data;
    struct BinarySortTreeNode* left;
    struct BinarySortTreeNode* right;
    struct BinarySortTreeNode* parent;
}BSTNode;

typedef struct BinarySortTree
{
    BSTNode* root;
}BSTree;

//树节点打印回调函数
typedef void (*PrintCall)(ElementType data);
//销毁树节点data域回调函数
typedef void (*DataDestroy)(ElementType data);
//树节点数据比较回调函数
typedef int (*DataCompare)(ElementType ctx, ElementType data);


//初始化二叉树
int BST_Init(BSTree* tree);
//创建二叉树,返回指针
BSTree* BST_Create();
// 插入
void BST_InsertElement(BSTree* tree, ElementType element, int(*func)(ElementType, ElementType));
//销毁整颗树
void BST_FreeTree(BSTree* tree, DataDestroy dataDestroy);
//前序遍历
void BST_PrevTravel(BSTree* tree, void (*func)(ElementType) );
//中序遍历
void BST_MidTravel(BSTree* tree, void (*func)(ElementType));
//后序遍历
void BST_PostTravel(BSTree* tree, void (*func)(ElementType));
//层序遍历
void BST_SeqTravel(BSTree* tree, void (*func)(ElementType), void (*DataDestroy)(ElementType ));
//查找值
BSTNode* BST_FindElement(BSTree* tree, ElementType element, int(*func)(ElementType, ElementType));
//删除
void BST_DeleteElement(BSTree* tree, ElementType element, int(*func)(ElementType, ElementType));
//获取叶子数量
int BST_GetLeafNUm(BSTree* tree);


 



#endif